#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	char ch1[10] = { 0 };
	char ch2[10] = { 0 };
	scanf("%s%s", ch1, ch2);
	int i = 0;
	int n1 = 1;
	int n2 = 1;
	while (ch1[i])
	{
		n1 *= ch1[i] - 'A' + 1;
		i++;
	}
	i = 0;
	while (ch2[i])
	{
		n2 *= ch2[i] - 'A' + 1;
		i++;
	}
	if (n1 % 47 == n2 % 47)
	{
		printf("GO\n");
	}
	else
	{
		printf("STAY\n");
	}
	return 0;
}